package com.by.utils;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/9 11:05
 * @注释
 */
public class StringUtils {
    /**
     * 将驼峰命名法转换为下划线命名法
     */
    public static String camelToUnderline(String camelCase) {
        if (camelCase == null || camelCase.isEmpty()) {
            return camelCase;
        }
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < camelCase.length(); i++) {
            char ch = camelCase.charAt(i);
            if (Character.isUpperCase(ch)) {
                result.append("_").append(Character.toLowerCase(ch));
            } else {
                result.append(ch);
            }
        }
        return result.toString();
    }
}